﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="html" />
  <xsl:template match="/ReportData">
    <html>
      <head>
        <title>
          TFS.VCS.Reports Report
        </title>
        <style type="text/css">
          body, td
          {
          font-family: Tahoma, Arial;
          font-size: 10pt;
          background-color: White;
          }
          .reportTable
          {
          width: 100%;
          }
          .detailSectionTitle
          {
          font-weight: bold;
          }
          .headerRow
          {
          background-color: #C0C0C0;
          font-weight: bold;
          text-align: center;
          }
          .footerText
          {
          text-align: center;
          font-size: 8pt;
          }
        </style>
      </head>
      <body>
        <div>
          <center>
            <h2>TFS 2010 Version Control Report</h2>
          </center>
        </div>
        <div>
          <h4>Report Details</h4>
          <table border="1" cellpadding="4" cellspacing="0" class="reportTable">
            <thead class="headerRow">
              <tr>
                <td>
                  Report Date
                </td>
                <td>
                  Team Project Collection Url
                </td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>
                  <xsl:value-of select="@creationDate" />
                </td>
                <td>
                  <xsl:value-of select="TeamProjectCollectionUrl" />
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div>
          <h4>Changesets</h4>
          <xsl:apply-templates select="Changesets" />
        </div>
        <xsl:apply-templates select="Exceptions" />
        <br />
        <hr size="1px" width="50%" />
        <div class="footerText">Generated by TFS.VCS.Reports</div>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Changesets">
    <table border="1" cellpadding="4" cellspacing="0" class="reportTable">
      <thead class="headerRow">
        <tr>
          <td>
            Changeset ID
          </td>
          <td>
            Created On
          </td>
          <td>
            Created By
          </td>
          <td>
            Comment
          </td>
          <td>
            Check-in Note
          </td>
          <td>
            Policy Override
          </td>
        </tr>
      </thead>
      <tbody>
        <xsl:for-each select="Changeset">
          <!--<xsl:sort select="@creationDate" order="descending" />-->
          <tr>
            <td>
              <xsl:value-of select="@id" />
            </td>
            <td>
              <xsl:value-of select="@creationDate" />
            </td>
            <td>
              <xsl:value-of select="Committer" />
            </td>
            <td>
              <xsl:value-of select="Comment" />
              <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            </td>
            <td>
              <xsl:value-of select="CheckinNote" />
              <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            </td>
            <td>
              <xsl:value-of select="PolicyOverride" />
              <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
            </td>
          </tr>
          <tr>
            <td colspan="6">
              <xsl:apply-templates select="Changes" />
              <xsl:apply-templates select="WorkItems" />
              <xsl:if test="Changesets">
                <div class="detailSectionTitle">Merge Source Changesets</div>
                <xsl:apply-templates select="Changesets" />
              </xsl:if>
            </td>
          </tr>
        </xsl:for-each>
      </tbody>
    </table>
  </xsl:template>
  <xsl:template match="Changes">
    <div>
      <div class="detailSectionTitle">Changes</div>
      <table border="1" cellpadding="4" cellspacing="0" class="reportTable">
        <thead class="headerRow">
          <tr>
            <td>
              Change
            </td>
            <td>
              Item Type
            </td>
            <td>
              Item
            </td>
            <td>
              Branch
            </td>
          </tr>
        </thead>
        <tbody>
          <xsl:for-each select="Change">
            <tr>
              <td>
                <xsl:value-of select="ChangeType" />
              </td>
              <td>
                <xsl:value-of select="ItemType" />
              </td>
              <td>
                <xsl:value-of select="Item" />
              </td>
              <td>
                <xsl:value-of select="Branch" />
                <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
              </td>
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </div>
  </xsl:template>
  <xsl:template match="WorkItems">
    <div>
      <div class="detailSectionTitle">Work Items</div>
      <table border="1" cellpadding="4" cellspacing="0" class="reportTable">
        <thead class="headerRow">
          <tr>
            <td>
              Work Item ID
            </td>
            <td>
              Title
            </td>
            <td>
              Description
            </td>
          </tr>
        </thead>
        <tbody>
          <xsl:for-each select="WorkItem">
            <tr>
              <td>
                <xsl:value-of select="@id" />
              </td>
              <td>
                <xsl:value-of select="Title" />
                <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
              </td>
              <td>
                <xsl:value-of select="Description" />
                <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
              </td>
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </div>
  </xsl:template>
  <xsl:template match="Exceptions">
    <div>
      <h4>Exceptions</h4>
      <table border="1" cellpadding="4" cellspacing="0" class="reportTable">
        <thead class="headerRow">
          <tr>
            <td>
              Message
            </td>
            <td>
              Type
            </td>
            <td>
              Stack Trace
            </td>
          </tr>
        </thead>
        <tbody>
          <xsl:for-each select="Exception">
            <tr>
              <td>
                <xsl:value-of select="Message" />
              </td>
              <td>
                <xsl:value-of select="Type" />
              </td>
              <td>
                <xsl:value-of select="StackTrace" />
              </td>
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </div>
  </xsl:template>
</xsl:stylesheet>
